    (function($){
        $.fn.extend({
            
            //pass the options variable to the function
            animateTSPT: function(options) {
                //Set the default values, use comma to separate the settings, example:
                var defaults = {
                    previewId: '[no previewId provided]',
                    detailId: '[no detailId provided]',
                    tileImageId: '[no tileImageId provided]',
                    delay: 300,
                    duration: 500
                }
                    
                var options = $.extend(defaults, options);
            return this.each(function() {
                    var o = options;
                    var obj = $(this);
                    
                    var stopFading = function() { 
						$(o.detailId).stop(true, true).fadeOut(o.duration);
				   		$(o.previewId).stop(true, true).fadeIn(o.duration);
				   		$(o.tileImageId).stop(true, false).animate({
					   		left: "0",
					   		opacity: 1
					   		}, o.duration, function() {
					   		// Animation complete.
					   		});	
					};

					$(o.previewId).mouseover(
							function () {
								$(this).delay(o.delay).fadeOut(o.duration);
								$(o.detailId).delay(o.delay).fadeIn(o.duration);
								$(o.tileImageId).delay(o.delay).animate({
							   		left: "50%",
							   		opacity: 0
							   		}, o.duration, function() {
							   		// Animation complete.
							   	 });
							   	 		   		
							}
						).mouseleave( // this is a workaround, because after the animation-end, this would be invoked.
								function(){
									var opacity = $(o.tileImageId).css("opacity");
									if(opacity != 0)
										stopFading();									
								}
						);
					// also invoke the the stopFading method, if mouse total leaves area.
					$(o.detailId).mouseleave(
							function () {
								stopFading();
							}
						);
                
            });
        }
        });
        
    })(jQuery);